package com.shsxt.crm.controller.customer;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.shsxt.common.util.Result;
import com.shsxt.crm.model.YgCusDevPlan;
import com.shsxt.crm.model.YgSaleChance;
import com.shsxt.crm.service.ICusDevPlanService;
import com.shsxt.crm.service.IMarketingService;
import com.shsxt.framework.context.BaseController;

/**
 * 客户开发计划
 * 
 * @author Mr.YongGan.Zhang
 */
@Controller
@RequestMapping("/cus_dev_plan")
public class CusDevPlanController extends BaseController {

	@Autowired
	private IMarketingService marketingService;

	@Autowired
	private ICusDevPlanService cusDevPlanService;

	@RequestMapping("/index.shtml")
	public ModelAndView index(@RequestParam("sid") Integer sid) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("cus_dev_plan_detail");
		// 根据id 查询 营销机会
		YgSaleChance chance = marketingService.queryYgSaleChanceBySid(sid);
		mv.addObject("saleChance", chance);
		return mv;
	}

	@PostMapping("/queryCusDevPlansByParams")
	@ResponseBody
	public Map<String, Object> queryCusDevPlansBySaleChanceId(YgCusDevPlan ygCusDevPlan) {
		return cusDevPlanService.queryCusDevPlansBySaleChanceId(ygCusDevPlan);
	}

	/**
	 * 添加客户开发计划
	 * 
	 * @param ygCusDevPlan
	 * @return
	 */
	@PostMapping("/insert")
	@ResponseBody
	public Result insertCusDevPlans(YgCusDevPlan ygCusDevPlan) {
		return cusDevPlanService.insertCusDevPlans(ygCusDevPlan);
	}

	@PostMapping("/delete")
	@ResponseBody
	public Result delCusDevPlans(Integer id) {
		return cusDevPlanService.delCusDevPlans(id);
	}

}